package cn.edu.cug.cs.gtl.docsrv.shp.querier;

import cn.edu.cug.cs.gtl.docsrv.shp.block.ShapeBlock;
import cn.edu.cug.cs.gtl.extractor.ShapeExtractor;
import org.opengis.feature.type.FeatureType;

public class DefaultFeatureQuerier extends DefaultGeometryQuerier implements FeatureQuerier{
    FeatureType featureType;
    public DefaultFeatureQuerier(ShapeBlock block) {
        super(block);
        if(block.getFeatures().size()>0)
            this.featureType = block.getFeatures().get(0).getFeatureType();
        else
            this.featureType=null;
    }


    @Override
    public FeatureType getFeatureType() {
        return this.featureType;
    }

    @Override
    public String toGeoJSON() {
        try {
            return ShapeExtractor.featuresToGeoJSON(getFeatureJSONs());
        }
        catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
